package xyz.zhzby.cyzx.security.security;

import io.swagger.annotations.ApiModel;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.stereotype.Component;
import xyz.zhzby.cyzx.servicebase.utils.MDUtil;

/**
 * @author zby
 * @date 2021/12/07
 */
@ApiModel("密码处理")
@Component
public class DefaultPasswordEncoder implements PasswordEncoder {

    public DefaultPasswordEncoder() {
        this(-1);
    }

    /**
     * @param strength the log rounds to use, between 4 and 31
     */
    public DefaultPasswordEncoder(int strength) {

    }

    public String encode(CharSequence rawPassword) {
        return MDUtil.encryption(rawPassword.toString());
    }

    public boolean matches(CharSequence rawPassword, String encodedPassword) {
        return encodedPassword.equals(MDUtil.encryption(rawPassword.toString()));
    }
}
